package com.yhstudio.designPattern.iterator;

public class BookShelfIterator implements Iterator {

    private BookShelf bookShelf;
    private int last = 0;

    public BookShelfIterator(BookShelf bookShelf) {
        this.bookShelf = bookShelf;
        this.last = 0;
    }

    @Override
    public Boolean hasNext() {
        return last < bookShelf.size();
    }

    @Override
    public Object next() {
        Book book = bookShelf.getBookAt(last);
        this.last++;
        return book;
    }
}
